/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javabeans;

import DAO.IGroupPlanImpl;
import Service.EventServiceImpl;
import Service.GroupPlanServiceImpl;
import Service.MemberServiceImpl;
import Service.PlanServiceImpl;
import java.awt.Color;
import java.awt.Point;
import java.util.Date;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 *
 * @author liweijiao
 */
public class test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
		/*ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        new String[] { "ApplicationContext.xml" });

        Contact contact2 = (Contact) context.getBean("ContactBean");

        System.out.println(contact2.getFirstname());*/

        MemberServiceImpl memberSI = new MemberServiceImpl();
        System.out.println(memberSI.register("Yi@efrei", "123", "Yi", "SHI", "female"));
        System.out.println(memberSI.register("li@efrei", "123", "Weijiao", "LI", "female"));
        System.out.println(memberSI.login("Yi@efrei", "123"));
        System.out.println(memberSI.login("Yi@efrei", "223"));
        System.out.println(memberSI.login("Yi@ece", "123"));
        EventServiceImpl eventSI = new EventServiceImpl();
        PlanServiceImpl planSI = new PlanServiceImpl();
        GroupPlanServiceImpl groupplanSI=new GroupPlanServiceImpl();

//        Date date = new Date();
//        date.getTime();
        Plan plan = planSI.newPlan("newplan", "plan1","li@efrei");
        Event event = planSI.addEvent("event1", "hotel", "2009", "0909", "newevent", 0, 0, "red", plan);
        Event event2 = planSI.addEvent("event2", "hotel", "2009", "0909", "newevent", 0, 0, "red", plan);
        Event event3 = planSI.addEvent("event3", "hotel", "2009", "0909", "newevent", 0, 0, "red", plan);
        System.out.println(plan.getPlanid());
        Plan plan1=planSI.getPlan(1);
        System.out.println(plan1.getEvents().size());
       Member member=memberSI.getMember("li@efrei");
       Member member2=memberSI.getMember("Yi@efrei");
       List<Plan> planlist=member.getPersonalplans();
       System.out.println("personalplan"+planlist.size());
       memberSI.createGroupPlan("groupplan1", "groupplan1", "li@efrei");
       memberSI.createGroupPlan("groupplan2", "groupplan2", "li@efrei");
       IGroupPlanImpl groupSI=new IGroupPlanImpl();

       System.out.println(groupSI.getGroupPlan(1).getGroupplanname());
      
      GroupPlan groupplan=memberSI.getGroupPlanList(member.getId()).get(0);

      Event event4 = groupplanSI.addGroupEvent("event4", "hotel", "2009", "0909", "newgroupevent", 0, 0, "red", groupplan);
        Event event5 = groupplanSI.addGroupEvent("event5", "hotel", "2009", "0909", "newgroupevent", 0, 0, "red", groupplan);
        Event event6 = groupplanSI.addGroupEvent("event6", "hotel", "2009", "0909", "newgroupevent", 0, 0, "red", groupplan);
      memberSI.joinGroup(member2, groupplan);
      memberSI.leaveGroup(member, groupplan);

      System.out.println(groupplanSI.getGroupEventList(1).size());
      groupplanSI.deleteGroupEvent(event5.getId(), groupplan.getGroupplanid());
      System.out.println(groupplanSI.viewAllGroupPlan().size());
      eventSI.deleteGroupEvent(4, 1);
      eventSI.deleteGroupEvent(6, 1);
      groupplanSI.deleteGroupPlan(groupplan);

    }
}
